package com.mooral.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.SortedSet;

import com.sun.org.apache.bcel.internal.generic.StoreInstruction;

public class Categories extends Beans {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2974427931939858260L;

	
	public void populate(String query) throws Exception {
		super.populate(new Category(), query);
	}
	
	public void populate(ResultSet resultSet) throws SQLException {
		super.populate(new Category(), resultSet);
	}
	
	public Category getBySlug(String slug){
		Iterator iterator = iterator();
		while(iterator.hasNext()){
			Category category = (Category) iterator.next();
			if(category.get("slug").equals(slug))return category;
			if(category.hasChilds()){
				category = category.getChilds().getBySlug(slug);
				if(category != null)return category;
			}
		}
		return null;
	}
}


